<template>
	<div>
		<h3>企业详细信息</h3>
		<el-form :model="form">
			<div class="clearfix">
				<el-form-item label="企业编号" :label-width="formLabelWidth" style="width: 500px; float: left">
					<el-input v-model="form.companyId" autocomplete="off" style="width: 420px" readonly></el-input>
				</el-form-item>
				<el-form-item label="企业名称" :label-width="formLabelWidth"
					style="width: 500px; float: left; margin-left: 50px">
					<el-input v-model="form.companyName" autocomplete="off" style="width: 420px" readonly></el-input>
				</el-form-item>
			</div>
			<div class="clearfix">
				<el-form-item label="证件类型" :label-width="formLabelWidth" style="width: 500px; float: left">
					<el-input v-model="form.documentName" autocomplete="off" style="width: 420px" readonly></el-input>
				</el-form-item>
				<el-form-item label="证件号码" :label-width="formLabelWidth"
					style="width: 500px; float: left; margin-left: 50px">
					<el-input v-model="form.documentNumber" autocomplete="off" style="width: 420px" readonly></el-input>
				</el-form-item>
			</div>
			<div class="clearfix">
				<el-form-item label="企业成立日期" :label-width="formLabelWidth" style="width: 500px; float: left">
					<el-input v-model="form.companyCreateTime" autocomplete="off" style="width: 420px" readonly>
					</el-input>
				</el-form-item>
				<el-form-item label="注册资本(万元)" :label-width="formLabelWidth"
					style="width: 500px; float: left; margin-left: 50px">
					<el-input v-model="form.registeredCapital" autocomplete="off" style="width: 420px" readonly>
					</el-input>
				</el-form-item>
			</div>
			<div class="clearfix">
				<el-form-item label="详细地址" :label-width="formLabelWidth" style="width: 500px; float: left">
					<el-input v-model="form.address" autocomplete="off" style="width: 420px" readonly></el-input>
				</el-form-item>
				<el-form-item label="职工人数" :label-width="formLabelWidth"
					style="width: 500px; float: left; margin-left: 50px">
					<el-input v-model="form.employeesNumber" autocomplete="off" style="width: 420px" readonly>
					</el-input>
				</el-form-item>
			</div>
			<div class="clearfix">
				<el-form-item label="登记日期" :label-width="formLabelWidth" style="width: 500px; float: left">
					<el-input v-model="form.registeredTime" autocomplete="off" style="width: 420px" readonly></el-input>
				</el-form-item>
				<el-form-item label="更新日期" :label-width="formLabelWidth"
					style="width: 500px; float: left; margin-left: 50px">
					<el-input v-model="form.updateTime" autocomplete="off" style="width: 420px" readonly></el-input>
				</el-form-item>
			</div>
		</el-form>
		<h3>企业高管基本信息</h3>
		<el-table :data="tableData.filter(data => !search || data.executiveId.toLowerCase().includes(search.toLowerCase()))"
			style="width: 100%" @selection-change="handleSelectionChange">
			<el-table-column type="selection" width="55"> </el-table-column>
			<el-table-column label="企业编号" prop="companyId"> </el-table-column>
			<el-table-column label="高管编号" prop="executiveId"> </el-table-column>
			<el-table-column label="高管名称" prop="executiveName"> </el-table-column>
			<el-table-column label="职务" prop="postName"> </el-table-column>
			<el-table-column label="性别" prop="sexName"> </el-table-column>
			<el-table-column label="出生日期" prop="birthday"> </el-table-column>
			<el-table-column label="学历" prop="educationName"> </el-table-column>
			<el-table-column label="登记日期" prop="registeredTime">
			</el-table-column>
			<el-table-column label="更新日期" prop="updateTime"> </el-table-column>
			<el-table-column width="250px" align="center">
				<template slot="header" slot-scope="scope">
					<el-input placeholder="请输入高管编号" v-model="search" clearable class="input-box">
						<i slot="prefix" class="el-input__icon el-icon-search"></i>
					</el-input>
				</template>
			</el-table-column>
		</el-table>
	</div>
</template>

<script>
	import { Business } from '@/api/';
	export default {
		props: ['id'],
		data() {
			return {
				activeIndex: '1',
				form: {
					companyId: "",
					companyName: "",
					documentName: "",
					documentNumber: "",
					companyCreateTime: "",
					registeredCapital: "",
					address: "",
					employeesNumber: "",
					registeredTime: "",
					updateTime: "",
				},
				search:'',
				tableData: [],
				formLabelWidth: '120px'
			};
		},
		created() {
			// 加载企业详细信息(包括企业高管信息);
			this.loadAllList(this.id);
		},
		methods: {
			// 获取企业详细信息(包括企业高管信息);
			async loadAllList(id) {
				// 没有参数就不用传参;
				let {
					status,
					data
				} = await Business.detail({id});
				if (status) {
					this.form = data.companies;
					this.tableData = data.executives;
				}
			},
			// 复选框选中个数的记录,以及控制是否选中;
			handleSelectionChange(val) {
				this.multipleSelection = val;
				this.selectionList = [],
					// 记录所有选中的企业的编号，放在selectionList数组中
					val.forEach(element => {
						this.selectionList.push(element.companyId);
					});
			},
		}
	}
</script>

<style scoped>
	.clearfix {
		width: 1200px;
		margin: 0 auto;
	}

	.clearfix::after {
		content: '';
		display: block;
		clear: both;
	}
	h3 {
		text-align: center;
	}
</style>
